package com.sfc.sdsr.server.commands;

import com.sfc.sdsr.common.model.Event;
import com.sfc.sdsr.server.ClientData;
import com.sfc.sdsr.server.dao.DaoFactory;

public class CreateEvent extends Command {

	private Event newEvent;
	
	public CreateEvent(ClientData clientData) {
		dao = DaoFactory.getDao();
		if (clientData.getOperationParameter() instanceof Event) {
			newEvent = (Event) clientData.getOperationParameter();
		} else {
			log.error("Can't create an event. Client Data corrupted, no Event found to Create");
			shouldExecute = false;
			returnObject = null;
		}
	}

	@Override
	public void execute() {
		log.info("Creating an event");
		returnObject = dao.createEvent(newEvent);
	}

}
